import os

from model.unit.base.Shape import Group


class Unit(Group):
    def __init__(self):
        super().__init__()
        self.unit_mesh = None
        self.json_obj = None
        self.section = None
        self.stl_path = ''
        self.object_list = []
        self.position_feature = None

    def save_stl(self, file_path='temp'):
        obj = self.unit_mesh
        if os.path.exists(file_path):
            os.remove(file_path)
        obj.export(file_path, file_type='stl')
        return os.path.abspath(file_path)

    def add_transform(self, transform):
        self.unit_mesh.apply_transform(transform)

